#ifndef BG_TILES_H
#define BG_TILES_H

#include "consts.h"
#include "cash.h"

class TILES :public QObject, public QGraphicsItemGroup
{
    Q_OBJECT
private:
    TILES *cover;

    QTimeLine *tl_bg_tiles;
    QVector<QPixmap*> *vect_pix;
    QVector<GRAPHICS_PIXMAP_ITEM*> *vect_blend_items;

    QRectF tiles_rect;
    QRectF scene_rect;
    QPoint size;
    QPoint tile_size;
    TILES_TYPE type;
    QString mission;
    QString blend_mission;
    MOVE_DIRECTION last_move;

    QGraphicsItemAnimation *anim_scale;

    int basic_anim_speed;
    int basic_move_speed;

    //для создания многослойности
    int factor;
    int factor_speed;

    bool is_cover;
    bool is_blended;
    bool is_cover_blend_connect;

    CASH *cash;

public:
    TILES(QRectF rect, TILES_TYPE new_type, QString mission, int factor = 2, bool is_cover = false, CASH *cash=0);

    void set_tiles_rect(QRectF rect);
    void Generate();

    QRectF boundingRect() const;

    void set_cover(TILES *tile);
    void set_basic_anim_speed(int value);

    void set_ActiveBlur(bool value);
    void set_time_line(QTimeLine *timeline);

    QPainterPath shape()const;

    void randomize();

    void set_mission(QString str_mission);
    void create_blend(QString str_mission);

    void set_blend_mission(QString str);

    ~TILES();

private:
    void init();

    void Generate_Terrain();
    void Generate_Edges();

    void load_Origin();

public slots:
    void slot_anim_forward();

    void move(MOVE_DIRECTION direction);
    void move_finish();

    void slot_blended_invis();

    void slot_blend_to_water();
    void slot_blend_to_city();

    void slot_to_water();
    void slot_to_city();

    void slot_cover_to_water();
    void slot_cover_to_city();


signals:
    void signal_invisible();
    void signal_blended_invis();

};

#endif // BG_TILES_H
